package com.hd.service.impl;

import com.hd.mapper.XInfoMapper;
import com.hd.pojo.XInfo;
import com.hd.service.XInfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 1 on 2017/11/30.
 */
@Service("xInfoService")
@Transactional
public class XInfoServiceImpl implements XInfoService {

    @Resource
    private XInfoMapper xInfoMapper;

    @Override
    public void addXInfo(XInfo xInfo) {
        xInfoMapper.add(xInfo);
    }

    @Override
    public XInfo searchXInfo() {
        return xInfoMapper.searchXInfo();
    }

    @Override
    public void enterXInfo(XInfo xInfo) {
        xInfoMapper.update(xInfo);
    }

    @Override
    public List<XInfo> searchXInfoByCaseId(Integer caseId, String[] xPosition) {
        List<XInfo> xInfos = new ArrayList<>();
        if(xPosition!=null &&xPosition.length>0) {
            for (int i = 0; i < xPosition.length; i++) {
                XInfo xInfo = xInfoMapper.searchXInfoByCaseId(caseId, xPosition[i]);
                xInfos.add(xInfo);
            }
        }
        return xInfos;
    }
}
